﻿#pragma once
#include "GLLObjectAddon.h"

namespace GLL
{
	template<typename Key>
	class ObjAddonSet
	{
	protected:
		typedef GLL_HashMap<Key, Value> ValVec;
		typedef typename ValVec::iterator	iterator;
		ValVec _vals;

		void _Add( const Key& key, Value val)
		{
			_vals[key] = val;
		}

		Value _Get( const Key& key )
		{
			ValVec::iterator iter = _vals.find(key);
			if(iter == _vals.end()){
				SS ss;ss << "no such value(" << key << ") in collection";
				GLL_Throw(ss);
				return nullptr;
			}
			return iter->second;
		}

		void _Remove( const Key& key )
		{
			ValVec::iterator iter = _vals.find(key);
			if(iter == _vals.end()) return;
			GLL_DEL(iter->second);
			_vals.erase(iter);		
		}

		void _ClearAll()
		{
			ValVec::iterator iter = _vals.begin();
			for(; iter != _vals.end(); ++iter)
			{
				GLL_DEL(iter->second);
			}
			_vals.clear();
		}
	};

};//GLL
